# ! /usr/bin/nev python
# -*-coding:utf-8*-
#author:Big Big
import requests
import time
import random
all_ip = []
with open('ips.txt')as fp:
    for ip in fp.readlines():
        ip = ip.strip()
        all_ip.append(ip)
ip_ok_list = []
print(all_ip)
for ip in all_ip:
    print(type(random.choice(all_ip)))
    proxies = {
        'http': 'http://' + ip
    }

    head = {'User-Agent': 'Mozilla/5.0(Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/103.0.0.0 Safari/537.36',
            'Cookie':'ll="118178"; bid=hBTXwjIDQlM; __utmc=30149280; __utmc=223695111; dbcl2="253965069:pqEdRW4JzZw"; ck=w6QE; _pk_ref.100001.4cf6=%5B%22%22%2C%22%22%2C1658906159%2C%22https%3A%2F%2Faccounts.douban.com%2F%22%5D; _pk_ses.100001.4cf6=*; __utma=30149280.1090864118.1658894726.1658894726.1658906159.2; __utmb=30149280.0.10.1658906159; __utmz=30149280.1658906159.2.2.utmcsr=accounts.douban.com|utmccn=(referral)|utmcmd=referral|utmcct=/; __utma=223695111.1366077635.1658894745.1658894745.1658906159.2; __utmb=223695111.0.10.1658906159; __utmz=223695111.1658906159.2.2.utmcsr=accounts.douban.com|utmccn=(referral)|utmcmd=referral|utmcct=/; __gads=ID=486c022ec899a81b-225000c958d5004c:T=1658906159:RT=1658906159:S=ALNI_MaGCd87xslxHSsJ4OYj1FgHCC0mDg; __gpi=UID=0000081a3eed6427:T=1658906159:RT=1658906159:S=ALNI_Ma4lM88pAI5xgH8s3g_clLXvZnk9Q; push_noty_num=0; push_doumail_num=0; _pk_id.100001.4cf6=4a66b7e38910d633.1658894745.2.1658907331.1658894755.'}

    r = requests.get(url='https://movie.douban.com/top250?start=0&filter=',proxies=proxies,timeout=(3,3),headers=head)
    if r.status_code==200:
        print(ip,'ok')
        ip_ok_list.append(ip)
    else:
        print(ip,'not ok')


    time.sleep(0.5)